package com.mashibing.disruptor.v1;

import com.lmax.disruptor.EventHandler;
import java.time.LocalTime;
import java.util.concurrent.TimeUnit;

public class LongEventHandler1 implements EventHandler<LongEvent> {

    @Override
    public void onEvent(LongEvent longEvent, long sequence, boolean endOfBatch) throws Exception {
//        System.out.printf("\033[34m %s ===>> %s ===>> LongEventHandler1-beforeSleep ===>> %s ===>> %s \033[0m\n",
//                Thread.currentThread().getName(), LocalTime.now(), sequence, longEvent.getValue());
//        TimeUnit.MILLISECONDS.sleep(1000);
        long value = longEvent.getValue();
        longEvent.setValue(value * 10);
        TimeUnit.MILLISECONDS.sleep(10);
        System.out.printf("\033[34m %s ===>> %s ===>> LongEventHandler1-afterSleep ===>> %s ===>> %s \033[0m\n",
                Thread.currentThread().getName(), LocalTime.now(), sequence, longEvent.getValue());
    }

}
